var videos = new Array
var curVideoIdx
var running = false

function addVideo(filename)
{
    //if (slides.indexOf(slidePath) != -1)
    //    return;
    videos.push(filename)
}

function removeVideo(filename)
{
    var idx = slides.indexOf(filename)
    if (idx === -1)
        return;
    videos.splice(idx, 1);
}

function startPlayer()
{
    if (videos.length <= 0)
        return;
    curVideoIdx = 0;
    running = true;
    vplayer.source = videos[curVideoIdx];
    vplayer.play()
    vplayer.turnon()
}

function stopPlayer()
{
    running = false;
    vplayer.stop()
    vplayer.turnoff()
}

function onStopped()
{
    if (!running) return;
    if (++curVideoIdx >= videos.length)
        curVideoIdx = 0;
    vplayer.source = videos[curVideoIdx];
    vplayer.play();
    console.log(videos[curVideoIdx]);
}
